#pragma once
#include "cgzITask.h"
class cgzCTimer;
class tagTimer : public cgzIData
{
public:
    friend class cgzCTimer;
    tagTimer(int64_t coockid,int64_t expiration);
    ~tagTimer();
    bool operator>(const tagTimer *other) const;

public:
    int64_t m_cookid;     // 回调凭证
    int64_t m_expiration; // 到期事件
};

class cgzCTimer : public cgzITask
{
public:
    cgzCTimer(cgzCThreadPool *pool,const char *name);
    ~cgzCTimer();
    bool run(int64_t nms) override;
    bool ret(tagTimer *cgzTask);
    bool todoret(tagTimer *cgzTask);

private:
    std::priority_queue<tagTimer *, std::vector<tagTimer *>, std::greater<tagTimer *>> m_timers; // 最小堆优先队列
};
